package br.com.news.service;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import br.com.news.utils.business.exception.BusinessException;
import br.com.news.utils.business.interfaces.ICategoriaBusiness;
import br.com.news.utils.database.beans.CategoriaBean;
import br.com.news.utils.service.exception.ServiceException;
import br.com.news.utils.service.interfaces.ICategoriaService;

@Named
public class CategoriaService implements ICategoriaService{

	@Inject
	private ICategoriaBusiness categoriaBusiness;

	@Override
	public List<CategoriaBean> findAll() throws ServiceException {
		try {
			return categoriaBusiness.findAll();
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}

	@Override
	public List<CategoriaBean> findCategoriaAtiva() throws ServiceException {
		try {
			return categoriaBusiness.findCategoriaAtiva();
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}
	
	@Override
	public List<CategoriaBean> categoriasMaisAcessadas() throws ServiceException {
		try {
			return categoriaBusiness.categoriasMaisAcessadas();
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}
	
	@Override
	public List<CategoriaBean> findByExample(CategoriaBean categoria) {
		return categoriaBusiness.findByExample(categoria);
	}
	
	@Override
	public List<CategoriaBean> findCategoriaByStatus(boolean status) throws ServiceException {
		try {
			return categoriaBusiness.findCategoriaByStatus(status);
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}
	
	@Override
	public void update(CategoriaBean categoria) throws ServiceException {
		try {
			categoriaBusiness.update(categoria);
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}
	
	@Override
	public void save(CategoriaBean categoria) throws ServiceException {
		try {
			categoriaBusiness.save(categoria);
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}
}
